package com.caigou.modules.channel.adapter

import android.text.TextUtils
import android.widget.TextView
import com.caigou.comm.base.utils.ImageLoader
import com.caigou.modules.channel.R
import com.caigou.modules.channel.bean.BannedItemBean

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/10/14
 */
class BlackHouseItemAdapter(dataset: MutableList<BannedItemBean>) : BaseQuickAdapter<BannedItemBean, BaseViewHolder>(R.layout.item_black_hose_list, dataset) {
    override fun convert(holder: BaseViewHolder, item: BannedItemBean) {
        holder.getView<TextView>(R.id.black_house_item_tv_nickname).text = item.nickName
        holder.getView<TextView>(R.id.black_house_item_tv_count).text = "共${item.bannedCount}次违规"
        holder.getView<TextView>(R.id.black_house_item_tv_ban_date).text = item.createTime
        holder.getView<TextView>(R.id.black_house_item_tv_reason).text = item.remark
        val result = if (item.bannedNum == 999) {
            "永久禁言"
        } else {
            "禁言${item.bannedNum}天"
        }
        holder.getView<TextView>(R.id.black_house_item_tv_result).text = result
        holder.getView<TextView>(R.id.black_house_item_tv_date).text = item.unlockTime
        if (!TextUtils.isEmpty(item.headImg)) {
            ImageLoader.load(context, item.headImg, holder.getView(R.id.black_house_item_iv_avatar))
        } else {
            holder.setImageResource(R.id.black_house_item_iv_avatar, R.drawable.img_comm_avatar)
        }
    }
}